import json
import time
import logging
import datetime

import QUANTAXIS as QA
from QAStrategy.QAStrategy.qastockbase import QAStrategyStockBase
from QAPUBSUB.QAPUBSUB.producer import publisher, publisher_routing
from QAPUBSUB.QAPUBSUB.consumer import subscriber
from QATrader.QATRADER.trader import QA_TRADER
from QIFIAccount.QIFIAccount.QARealtimeStockSim import QIFI_StockSIM_Account
from QUANTAXIS_RealtimeCollector.QARealtimeCollector.collectors.stock_min_bar_collector import QARTCStockMinBar
from QUANTAXIS_RealtimeCollector.QARealtimeCollector.datahandler.stock_resampler import QARTCStockBarResampler


def main():
    codes = ['000100']

    # unsubscribe codes
    print('start unsubscribe codes')
    for code in codes:
        publisher_routing(exchange='QARealtime_Market', routing_key='stock').pub(
            json.dumps({
                'topic': 'unsubscribe',
                'code': code
            }), routing_key='stock'
        )
        print('unSubscribe code %s' % code)


if __name__ == "__main__":
    main()
